const originalWarn = console.warn;
console.warn = function (message, ...args) {
  if (typeof message === 'string' && message.includes('findDOMNode')) {
    return; // 忽略包含 'findDOMNode' 的警告
  }
  originalWarn(message, ...args); // 其他警告正常输出
};

import React from 'react';
import { Routes, Route } from 'react-router-dom';
import ErrorBoundary from './error-boundary';
import LoginPage from './components/LoginPage';
// import MainLayout from './layouts/MainLayout';
import PageNotFound from './components/PageNotFound';
import './index.scss';
// import { AuthProvider } from './context/AuthContext';
// import ProtectedRoute from './components/ProtectedRoute';
// import HomePage from '@/pages/HomePage/HomePage';
// import Charts from '@/pages/Charts/Charts';
// import Mine from '@/pages/Mine/Mine';
import { Suspense, lazy } from 'react';

const MainLayout = lazy(() => import('@/layouts/MainLayout'));
const HomePage = lazy(() => import('@/pages/HomePage/HomePage'));
const Charts = lazy(() => import('@/pages/Charts/Charts'));
const Mine = lazy(() => import('@/pages/Mine/Mine'));

import Detail from '@/pages/Charts/Detail/Detail';


function App() {

  return (
    <ErrorBoundary>
      <Suspense fallback={<div>Loading...</div>}>
        <Routes>
          <Route path="/" element={<LoginPage />} />
          <Route path="/main" element={<MainLayout />} >
            <Route path="home" element={<HomePage />} />
            <Route path="charts" element={<Charts />} />
            <Route path="mine" element={<Mine />} />
          </Route>
          <Route path="detail/:id" element={<Detail />} />
          <Route path="*" element={<PageNotFound />} />
        </Routes>
      </Suspense>
    </ErrorBoundary>
  );
}

export default App;
